#include "gobangboard.h"

#include "config.h"

GobangBoard::GobangBoard(QWidget *parent) : QWidget(parent)
{
    gobang.reset(new Gobang(BOARD_SIZE));
    init_board();
}

void GobangBoard::init_board() {
    uint8_t len = ENTRY_LENGTH;
    uint8_t size = BOARD_SIZE;

    layout.reset(new QGridLayout(this));
    layout->setSpacing(0);
    for (uint8_t i = 0; i < size; ++i) {
        for (uint8_t j = 0; j < size; ++j) {
            BoardEntry* entry = new BoardEntry(i, j, gobang.get());
            entry->setFocusPolicy(Qt::ClickFocus);
            entry->setFixedSize(len, len);
            connect(entry, SIGNAL(game_over(int, std::string)),
                    this, SIGNAL(game_over(int, std::string)));
            layout->addWidget(entry, i, j);
        }
    }
}

